#include "../include/head.h"

int makeworker(shareRes_t *share,int *epfd, pthread_data_t *pthread_data, int *clientInfo, int *exitFlag, pthread_mutex_t *mutex_client_info, taskQueue_t *queue_arr,pthread_mutex_t *long_queue_mutex,pthread_mutex_t *short_queue_mutex,pthread_cond_t *long_queue_cond,pthread_cond_t *short_queue_cond)
{
    for (int i = 0; i < pthread_data->workernum;i++)
    {
        share[i].pthread_data = pthread_data;
        share[i].pclient_info = clientInfo;
        share[i].exitflag=exitFlag;
        share[i].mutex_client_info=mutex_client_info;
        if(i == 0)
        {
            share[i].taskqueue = queue_arr[0];
            share[i].mutex_taskqueue = short_queue_mutex;
            share[i].cond = short_queue_cond;
        }
        if(i > 0)
        {
            share[i].taskqueue = queue_arr[1];
            share[i].mutex_taskqueue = long_queue_mutex;
            share[i].cond = long_queue_cond;
        }
        //printf("makeworker queuearr %p share.taskque %p\n",&queue_arr[i],&share[i].taskqueue);

        share[i].epfd = epfd;
       

        pthread_create(&share[i].pthread_data->ptidarr[i], NULL, pthread_enter, &share[i]);
    }

    return 0;

}
